﻿@model VisaApp.Helper.PagedData<VisaApp.Models.NewsModel>
           
<script type="text/javascript">
    $(document).ready(function () {
        $(".page-number").live("click", function () {
            var page = parseInt($(this).html());
            $.get("/Quantri/ListNews?&page=" + page, function (data) {
                $("#DivListCate").html("");
                $("#DivListCate").html(data);
            });
        });

        $("a.deteleCate").click(function () {
            var $this = $(this);
            var CateName = $this.closest('tr').find('.spanNameCate').html();
            if (confirm("Bạn muốn xóa Tin : " + CateName + "")) {
                var Cateid = $this.closest('tr').find('.Cate-id').html();
                var pageID = parseInt($(".page-number-Current").html());
                $.get("/Quantri/DeteleNews?id=" + Cateid, function () {
                    $.get("/Quantri/ListNews?&page=" + pageID, function (data) {
                        $("#DivListCate").html("");
                        $("#DivListCate").html(data);
                        alert("xóa chuyên Tin " + CateName + " Thành công");
                    });
                });
            }
        });

    });

</script>

<table width="100%">
    <tr>
        <th>
            Name
        </th>
        <th>
            Trạng thái
        </th>
        <th>
            Hiển thị trang chủ
        </th>
         <th>
            Hình ảnh
        </th>
        <th>
            ngày Tạo
        </th>
        <th>
            Sửa
        </th>
        <th>
            Xóa
        </th>
    </tr>
    @if (Model.Data != null)
    {
        foreach (var item in Model.Data)
        {
            <tr>
                <td>
                    <span class="Cate-id" style="display:none;">@item.Id</span>
                    <span class="spanNameCate">@item.Name </span>
                </td>
                <td>
                    <span class="spanNameTt">@item.ALowHome </span>
                </td>
                <td>
                    <span class="spanNameTt">@item.Trangthai </span>
                </td>
                <td>
                     <img src="@item.Images" width="70px" height="40px" />
                 </td>
                <td>
                    @String.Format("{0:dd/MM/yyy HH:mm}", item.DateCreate)
                </td>
                <td>
                   @Html.ActionLink("Edit", "_EditNews", "Quantri", new { id = item.Id }, new { @class = "t-button" })

                </td>
                <td>
                    <a href="javascript:void(0);" class="t-button deteleCate" id="deteleCate">Xóa</a>
                </td>
            </tr>
        }
    }
</table>
<table>
    <tr>
        <td colspan="3">
            @for (int m = 1; m <= Model.NumberOfPages; m++)
            {
                if (m == Model.CurrentPage)
                {
                <a class="page-number-Current" href="javascript:void(0);">@m</a>
                }
                else
                {
                <a class="page-number" href="javascript:void(0);">@m</a>
                }
            }
        </td>
    </tr>
</table>
